<!-- Copyright 2014 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!--
Has children: cxx-docnum, time[pubdate], cxx-editor, cxx-revises,
and <h1> for the title.

The document stage can be set in two ways:
  1. Add a 'cxx-draft', 'cxx-pdts', or `cxx-dts' class to the <body> element.
  2. Set the <cxx-titlepage stage> attribute to 'draft', 'pdts', or `dts`.
Each will be propagated to the other.
We'll add more stages as our documents get to them.

cxx-titlepage sets the document title based on its <h1> child.
-->
<polymer-element name="cxx-titlepage" attributes="stage">
  <template>
    <style>
      :host, .page { display: block; min-height: 100%; }
      .page { page-break-before: always; page-break-after: always; min-height: 100vh; margin-bottom: 2em; }
      @media print {
        /* Using an exact height for printed documents works around a bug in
           Prince that breaks footnotes when the html/body height is set to
           100%. */
        .page { height: 8.8in; }
      }

      /* position:relative on :host makes position:absolute on its children work
         relative to :host's bounds. */
      .page { position: relative; }
      table td, table th { border: none; }

      :host-context(body.cxx-draft) .header { position: absolute; right: 0; top: 0; }
      :host-context(body.cxx-draft) h1 { position: absolute; top: 40%; text-align: center; }
      :host-context(body.cxx-draft) p.warning { position: absolute; bottom: 5%; }

      :host-context(body.cxx-pdts, body.cxx-dts, body.cxx-ts) .header { position: absolute; right: 0; top: 0; text-align: right; }
      :host-context(body.cxx-pdts, body.cxx-dts, body.cxx-ts) .header ::content cxx-docnum { font-size: 150%; }
      :host-context(body.cxx-pdts, body.cxx-dts, body.cxx-ts) .header cxx-docnum { font-size: 150%; }
      :host-context(body.cxx-pdts, body.cxx-dts, body.cxx-ts) hgroup { position: absolute; top: 30%; }
      :host-context(body.cxx-pdts, body.cxx-dts, body.cxx-ts) hgroup * { margin: 0; }
      :host-context(body.cxx-pdts, body.cxx-dts, body.cxx-ts) hgroup h1 { font-size: 150%; font-weight: bold; }
      :host-context(body.cxx-pdts, body.cxx-dts, body.cxx-ts) hgroup h2 { font-size: 100%; font-weight: normal; }
      :host-context(body.cxx-pdts, body.cxx-dts, body.cxx-ts) .footer { position: absolute; left: 0; bottom: 5%; }
      :host-context(body.cxx-pdts, body.cxx-dts, body.cxx-ts) figure { border: #111 solid 1px; padding: 10px; margin-left: auto; margin-right: auto; }
      :host-context(body.cxx-pdts, body.cxx-dts, body.cxx-ts) figcaption { text-align: center; font-weight: bold; }
      :host-context(body.cxx-pdts, body.cxx-dts, body.cxx-ts) .warning { position: absolute; bottom: 20%; }
      :host-context(body.cxx-pdts, body.cxx-dts, body.cxx-ts) .copyright address { font-style: normal; margin-left: 2em; }
      :host-context(body.cxx-pdts, body.cxx-dts, body.cxx-ts) .copyright address a { color: inherit; text-decoration: inherit; }

      th { text-align: left; vertical-align: top; }
    </style>
    <template if="{{stage == 'draft'}}">
      <div class="page">
        <table class="header">
          <template if="{{docnum}}">
            <tr><th>Document Number:</th><td><content select="cxx-docnum"></content></td></tr>
          </template>
          <template if="{{hasPubdate}}">
            <tr><th>Date:</th><td><time pubdate><span class="pubyear">{{pubyear}}</span>-{{pubmonth}}-{{pubday}}</time></td></tr>
          </template>
          <template if="{{revises}}">
            <tr><th>Revises:</th><td><content select="cxx-revises"></content></td></tr>
          </template>
          <template if="{{editor}}">
            <tr><th>Editor:</th><td><content select="cxx-editor"></content></td></tr>
          </template>
        </table>
        <h1>Working Draft, {{title}}</h1>
        <p class="warning"><strong>Note: this is an early draft. It’s known to be
        incomplet and incorrekt, and it has lots of b<span
        style="margin-left: -1.2pt; margin-right: 1pt">a</span>d<span
        style="width:1.5em"> </span>for<span
        style="margin-left:-3pt; margin-right:0.6pt">mat</span>ti<span
        style="position:relative; top:-0.15ex">n</span>g.</strong></p>
      </div>
    </template>

    <template if="{{stage == 'pdts' || stage == 'dts' || stage == 'ts'}}">
      <div class="page">
        <div class="header">
          <template if="{{stage == 'pdts' || stage == 'dts'}}">
            <strong>ISO/IEC JTC1 SC22 WG21 <content select="cxx-docnum"/></content></strong><br/>
            Date: <time pubdate><span class="pubyear">{{pubyear}}</span>-{{pubmonth}}-{{pubday}}</time><br/>
            <template if="{{stage == 'pdts'}}">
              ISO/IEC PDTS <content select="cxx-project-number"></content><br/>
            </template>
            <template if="{{stage == 'dts'}}">
              ISO/IEC DTS <content select="cxx-project-number"></content><br/>
            </template>
          </template>
          <template if="{{stage == 'ts'}}">
            <strong class="docname">ISO/IEC <content select="cxx-project-number"></content>:<span class="pubyear">{{pubyear}}</span></strong><br/>
          </template>
          ISO/IEC JTC1 SC22 WG21<br/>
          Secretariat: ANSI
        </div>
        <hgroup>
          <h1>Programming Languages — {{title}}</h1>
          <template if="{{title_fr}}">
            <h2>Langages de programmation — {{title_fr}}</h2>
          </template>
        </hgroup>
        <figure class="warning">
          <figcaption>Warning</figcaption>
          <p>This document is not an ISO International Standard. It is distributed for review and comment. It is
          subject to change without notice and may not be referred to as an International Standard.
          </p>
          <p>Recipients of this draft are invited to submit, with their comments, notification of any relevant
          patent rights of which they are aware and to provide supporting documentation.</p>
        </figure>
        <div class="footer">
          <template if="{{stage == 'pdts'}}">
            Document type: Proposed Draft Technical Specification<br/>
            Document stage: (30) Committee<br/>
          </template>
          <template if="{{stage == 'dts'}}">
            Document type: Draft Technical Specification<br/>
            Document stage: (40) Enquiry<br/>
          </template>
          <template if="{{stage == 'ts'}}">
            Document type: Technical Specification<br/>
            Document stage: (60) Publication<br/>
          </template>
          Document language: E
        </div>
      </div>
      <div class="page">
        <figure class="copyright">
          <p>© ISO {{pubyear}}</p>
          <p>
            All rights reserved. Unless otherwise specified, no part
            of this publication may be reproduced or utilized
            otherwise in any form or by any means, electronic or
            mechanical, including photocopying, or posting on the
            internet or an intranet, without prior written permission.
            Permission can be requested from either ISO at the address
            below or ISO's member body in the country of the requester.
          </p>
          <address>
            ISO copyright office<br>
            Case postale 56 · CH-1211 Geneva 20<br>
            Tel. + 41 22 749 01 11<br>
            Fax + 41 22 749 09 47<br>
            E-mail <a href="mailto:copyright@iso.org">copyright@iso.org</a><br>
            Web <a href="http://www.iso.org">www.iso.org</a>
          </address>
          <p>Published in Switzerland.</p>
        </figure>
      </div>
    </template>

    <template if="{{!completedDomReady}}">
      <!--
        Work around
        https://github.com/webcomponents/webcomponentsjs/issues/112 by
        making sure every child element is included in the shadow dom until
        we've extracted its information.
      -->
      <content></content>
    </template>
  </template>
  <script src="titlepage.js"></script>
</polymer-element>
<polymer-element name="cxx-project-number" noscript>
  <!-- Find your project number at https://isocpp.org/std/status. -->
  <template><content></content></template>
</polymer-element>
<polymer-element name="cxx-docnum" noscript class="docname">
  <template><content></content></template>
</polymer-element>
<polymer-element name="cxx-editor" noscript>
  <template><content></content></template>
</polymer-element>
